package info.openlvb.openface.client.base.machine;

import com.google.gwt.event.logical.shared.OpenEvent;
import com.google.gwt.event.logical.shared.OpenHandler;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class MachineFunctionsPanel extends VerticalPanel {

	DisclosurePanel addMachine, listMachine;
	ListMachinePanel listMachinePanel;
	
	public MachineFunctionsPanel(){
		addMachine = new DisclosurePanel("Ajouter un ordinateur");
		addMachine.setAnimationEnabled(true);
		addMachine.setContent(new AddMachinePanel());
		
		listMachine = new DisclosurePanel("Lister les ordinateurs");
		listMachine.setAnimationEnabled(true);
		listMachinePanel = new ListMachinePanel();
		listMachine.setContent(listMachinePanel);
		
		addMachine.addOpenHandler(new OpenHandler<DisclosurePanel>() {
			public void onOpen(OpenEvent<DisclosurePanel> event) {
				listMachine.setOpen(false);
			}
		});
		listMachine.addOpenHandler(new OpenHandler<DisclosurePanel>() {
			public void onOpen(OpenEvent<DisclosurePanel> event) {
				addMachine.setOpen(false);
				listMachinePanel.refresh();
			}
		});
		add(addMachine);
		add(listMachine);
	}
}
